﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using ConsoleApplication9;

namespace ConsoleApplication9
{
    internal class Program
    {
        static void Main()
        {
            var name = Console.ReadLine();
            var persons = FindPersonByName(name).GetEnumerable();
        }

        static Query<Person> FindPersonByName(string name)
        {
            var command = new SqlCommand();
            var commandText = "SELECT Id, Name FROM Person WHERE 1=1";
            if (string.IsNullOrEmpty(name))
            {
                commandText = " AND Name = @Name";
                command.Parameters.AddWithValue("@Name", name);
            }
            command.CommandText = commandText;
            return command.Query<Person>();
        }

        [Test]
        void FindPersonByNameTest() 
        {
            QueryChecker.Check(FindPersonByName("TestName"));
            QueryChecker.Check(FindPersonByName(null));
        }


        public static IEnumerable<T> Query<T>(this SqlConnection it, string text, object arg)
        {
            throw new NotImplementedException();
        }

        public static IEnumerable<T> GetEnumerable<T>(this Query2<T> it, SqlConnection it2)
        {
            throw new NotImplementedException();
        }
    }

    public struct Nullable2<T> : IQwe where T : struct
    {
        
    }

    public interface IQwe
    {
    }

    public class Query2<T>
    {
        public Query2(string text, object arg)
        {
        }
    }

    public class Person
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
}
